from nicegui import ui


from nicegui import ui, app

# https://pywebview.flowrl.com/examples/drag_region.html
app.native.window_args.update({"easy_drag": False})


def echarts_options():
    return {
        "title": {"text": "历史曲线"},
        "tooltip": {"trigger": "axis"},
        "legend": {},
        "toolbox": {
            "show": "true",
            "feature": {
                "dataZoom": {"yAxisIndex": "none"},
                "magicType": {"type": ["line", "bar"]},
                "restore": {},
            },
        },
        "xAxis": {
            "type": "category",
            "boundaryGap": "false",
            "data": list(range(0, 13)),
        },
        "yAxis": {"type": "value"},
        "dataZoom": [
            {
                "type": "slider",
                "xAxisIndex": "0",
                "start": "0",
                "end": "100",
                "readOnly": "true",
            }
        ],
        "series": [
            {
                "name": "S1",
                "type": "line",
                "data": list(range(0, 13)),
                "symbol": "none",
            },
        ],
    }


# 此区域可以拖拽移动窗体，关键 pywebview-drag-region
ui.element("div").classes("w-full h-[10px] pywebview-drag-region bg-blue-100")


chart = ui.echart(echarts_options())


ui.run(
    native=True,
    reload=False,
    frameless=True,
    # fullscreen=True,
    host="127.0.0.1",
    port=9001,
)
